<?php

session_start();

define('DB_HOST',   'yallara.cs.rmit.edu.au:53936');
define('DB_NAME',   'happyendings');

define('DB_USER',   '');
define('DB_PW',     '');

if (!$dbconn = mysql_connect(DB_HOST, DB_USER, DB_PW)) {
  echo 'Could not connect to mysql on ' . DB_HOST . "\n";
  exit;
}

if (!mysql_select_db(DB_NAME, $dbconn)) {
  echo 'Could not use database ' . DB_NAME . "\n";
  echo mysql_error() . "\n";
  exit;
}

echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">';
echo '<head>';
	echo '<title>Welcome Administrator</title>';
	echo '<link href="template.css" type="text/css" rel="stylesheet" />';
	echo '<link href="admin.css" type="text/css" rel="stylesheet" />';

echo '</head>';

echo '<body>';
echo '<div id ="wrapper">';
echo '<!--wrapper start-->';

echo '<a href = "index.html"><div id = "logo"></div></a>';
echo '<div id="navBar">';
echo '<!--nav bar start-->';
echo '<div class = "home"><a href ="index.php"><div id="homeLink"><div id ="homeLinkText">Home</div></div></a></div>';
echo '<div class = "search"><a href = "search.html"><div id ="searchLink"><div id ="searchLinkText">Search</div></div></a></div>';
echo '<div class ="contactUs"><a href = "contactUs.html"><div id ="contactUsLink"><div id ="contectUsText">FAQ</div></div></a></div>';
echo '<div class = "register"><a href = "register.php"><div id ="registerLink"><div id ="registerText">Register</div></div></a> </div>';
echo '<!--nav bar finish-->';
echo '</div>';

echo '<div id = "form">';
echo '<form action = "postdelete.php" method = "post">';
echo '<table>';
echo '<tr>';
echo '<td>';
echo 'Delete Post:';
echo '</td>';
echo '<td>';
echo '<input type="text" name="postid" id="postid" value="Enter Post ID" />';
echo '</td>';
echo '<td>';
echo '<input type = "submit" value = "Go" name = "userDelete"/>';
echo '</td>';
echo '</tr><!--first row-->';
echo '</form>';


echo '<form action = "usersuspend.php" method = "post">';
echo '<tr>';
echo '<td>';
echo 'Suspend user:';
echo '</td>';
echo '<td>';
echo '<input type="text" name="usersuspend" id="usersuspend" value="Enter user ID"/>';
echo '</td>';
echo '<td>';
echo '<input type = "submit" value = "Go" />';
echo '</td>';
echo '</tr><!-- second row-->';
echo '</form>';


echo '<form action = "userunsuspend.php" method="post">';
echo '<tr>';
echo '<td>';
echo 'Unsuspend User:';
echo '</td>';
echo '<td>';
echo '<input type="text" name="userunsuspend" id="userunsuspend" value="Enter user ID"/>';
echo '</td>';
echo '<td>';
echo '<input type = "submit" value = "Go" />';
echo '</td>';
echo '</tr><!--third row-->';
echo '</form>';


echo '<form action = "userunsuspend.php" method = "post">';
echo '<tr>';
echo '<td>Suspended Users:</td>';
echo '<td>';
echo '<select>';
echo '<option>Users to be populated from the database</option>';

	$query = "SELECT user_id FROM user WHERE is_banned=1";
	mysql_select_db("happyendings", $dbconn);
	$result = mysql_query($query, $dbconn);
	$row = mysql_fetch_array($result);

	$i=0;
	while($row = mysql_fetch_array($result)) 
	{
	   echo "<option value =".$i.">".$row['is_banned']."</option>";
	   $i++;
	}
	
echo '</select>';
echo '</td>';
echo '<td> <input type = "submit" value = "unsuspendUsers" /></td>';
echo '</tr><!-- fourth Row-->';
echo '</form>';


echo '</table>';
echo '</div>';
echo '<!--wrapper finish-->';
echo '</div>';
echo '</body>';
echo '</html>';
?>
